Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MyST-NB for rendering notebooks, and JupySQL for running SQL #566

Merged
merged 3 commits into from
Jan 24, 2025
Merged

Conversation

amotl
Copy link
Member

@amotl amotl commented Jan 11, 2025

About

The documentation can now include traditional Jupyter Notebooks in .ipynb format, as well as text-based notebooks written in Markdown, per MyST-NB.

By streamlining running SQL and plotting large datasets in Jupyter Notebooks, CrateDB can provide details closer to what others are offering, per JupySQL.

Details

The patch adds two addons to the documentation stack.

Preview

/cc @karynzv, @hlcianfagna, @hammerhead, @wierdvanderhaar, @ckurze, @msbt, @WalBeh, @simonprickett

@amotl amotl changed the title Add MyST-NB, for rendering Jupyter notebooks Add MyST-NB for rendering notebooks, traditional and text-based Jan 11, 2025
@amotl amotl marked this pull request as ready for review January 11, 2025 21:40
docs/myst/cell.md Outdated Show resolved Hide resolved
docs/myst/cell.md Outdated Show resolved Hide resolved
docs/myst/cell.md Outdated Show resolved Hide resolved
@amotl amotl changed the title Add MyST-NB for rendering notebooks, traditional and text-based Add MyST-NB for rendering notebooks, and JupySQL for running SQL Jan 11, 2025
Copy link

@surister surister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice, thanks for the work, checking it in dark mode, https://crate-docs-theme--566.org.readthedocs.build/en/566/myst/notebook-text.html table is hard to read.
image

@msbt
Copy link
Collaborator

msbt commented Jan 16, 2025

thanks @surister, using

div.cell_output table {
  color: var(--color-content-foreground);
}

already makes it better, but the alternating table color is not ideal either, maybe this could work?

div.cell_output tbody tr:nth-child(2n+1) {
  background: var(--color-background-hover);
}

wdyt?

@surister surister self-requested a review January 22, 2025 17:11
Comment on lines +7 to +14
"(notebook-traditional)=\n",
"\n",
"# Notebook (traditional)\n",
"\n",
"The documentation can include traditional Jupyter Notebooks in .ipynb JSON format.\n",
"They are rendered using [MyST-NB].\n",
"\n",
"[MyST-NB]: https://myst-nb.readthedocs.io/\n"
Copy link
Member Author

@amotl amotl Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: This creates a reference attached to the subsequent headline, as introduced by traditional Sphinx/MyST the other day.

(notebook-traditional)=
# Notebook (traditional)

Comment on lines +6 to +11
"source": [
"# Notebook (traditional)\n",
"\n",
"This is just a placeholder.\n",
"See {ref}`notebook-traditional` instead."
]
Copy link
Member Author

@amotl amotl Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: This cell's Markdown links to the reference displayed here, using

{ref}`notebook-traditional`

In this spirit, MyST-NB demonstrates that it converges notebooks into real documents, thus they become parts of Sphinx' native document tree, so they can use all the features, including linking between them as if they were traditional reStructuredText or Markdown documents.

Comment on lines +38 to +43
```{code-cell} ipython3
# Run query using JupySQL.
%reload_ext sql
%sql sqlite:///population.db
%sql SELECT * FROM acs2012_5yr_population ORDER BY total_population DESC LIMIT 10;
```
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting the dark mode bug here, @surister.

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to @msbt's excellent suggestion, submitting the fix 6221203 was easy, and it solves the problem perfectly well. Thank you very much. 💯

image

Copy link
Member Author

@amotl amotl Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To conclude this, filing an issue with MyST-NB about it would be perfectly sensible, sharing @msbt's CSS snippet which fixes the problem for us.

/*
Fix dark mode for tables in Jupyter Notebooks rendered by MyST-NB.
https://github.com/crate/crate-docs-theme/pull/566
*/
div.cell_output table {
  color: var(--color-content-foreground);
}
div.cell_output tbody tr:nth-child(2n+1) {
  background: var(--color-background-hover);
}

Copy link
Member Author

@amotl amotl Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] filing an issue with MyST-NB about it would be perfectly sensible [...]

In the spirit of upstreaming changes, let me share a few pointers to existing issues about dark mode already (I haven't digested them, so it's really just for reference and information sharing).

Also having backlinks on them can help others to resolve the problem in an ad hoc manner, and evaluate our fix, possibly also on other spots than just tables, until a new release of MyST-NB will include a relevant fix. Those have been picked up in the same way:

@amotl amotl merged commit 6dc0039 into main Jan 24, 2025
8 checks passed
@amotl amotl deleted the myst-nb branch January 24, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants